package com.ruoyi.service.impl;

import com.ruoyi.domain.Device;
import com.ruoyi.mapper.DeviceMapper;
import com.ruoyi.service.DeviceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
/*
  @ClassName: DeviceServiceImpl
 * @Description:
 * @author: lifei
 * @date: 2025年02月26日 14:54
 */

/**
 * 用户设备服务实现类，实现了UserDeviceService接口中的业务方法。
 *
 * @author lifei
 */
@Service
public class DeviceServiceImpl implements DeviceService {

    private final DeviceMapper deviceMapper;

    @Autowired
    public DeviceServiceImpl(DeviceMapper deviceMapper) {
        this.deviceMapper = deviceMapper;
    }

    @Override
    public void addUserDevice(Device userDevice) {
        deviceMapper.insertUserDevice(userDevice);
    }

    @Override
    public void removeUserDevice(Long deviceId) {
        deviceMapper.deleteUserDevice(deviceId);
    }

    @Override
    public void updateUserDevice(Device userDevice) {
        deviceMapper.updateUserDevice(userDevice);
    }

    @Override
    public Device getUserDeviceById(Long deviceId) {
        return deviceMapper.getUserDeviceById(deviceId);
    }

    @Override
    public List<Device> getUserDevicesByUserId(Long userId) {
        return deviceMapper.getUserDevicesByUserId(userId);
    }
}
